/*
 * Database.java
 * 
 * @version 1.0, April 2, 2011
 * CS 2340 Team 10: Cyberdyne Systems
 */
package edu.gatech.oad.cyberdoc.database;

/**
 * Specifies the methods required of a database connector.
 * 
 * @author John Girata
 * @version 1.0, April 2, 2011
 */
public interface Database {

	/**
	 * Saves an object to the database. All fields specified in the result of a
	 * call to object.toJSONObject() will be saved in the database.
	 * 
	 * @param object
	 *            The object to save
	 * @throws DatabaseException
	 *             If an error occurs while saving the object to the database
	 */
	void save(DatabaseSerializable object) throws DatabaseException;

	/**
	 * Creates instances of all classes currently saved in the database. No
	 * effort is made to ensure that duplicate objects are not created.
	 * Therefore, this method should only be invoked on a "blank" system.
	 * 
	 * @return The number of objects loaded from the database
	 * @throws DatabaseException
	 *             If an error occurs while reading from the database
	 * @throws NoSuchMethodException
	 *             If an object saved in the database does not have the required
	 *             constructor
	 */
	int load() throws DatabaseException;

	/**
	 * Removes all entries in this database.
	 */
	void clear();
}
